package com.recipe.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.Random;

/**
 * Created by mushuangcheng on 2019/1/19
 */
@Controller
public class IndexController {
    @RequestMapping(value = {"/","/index"})
    public String index(Map<String,Object> map){
        long t = System.currentTimeMillis();//获得当前时间的毫秒数
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyMMdd");

        Random rd = new Random(t);//作为种子数传入到Random的构造器中
        map.put("recipecode"," S"+rd.nextInt(9999999));
        map.put("diagnosecode"," "+sdf2.format(t)+rd.nextInt(9999));
        map.put("date"," "+sdf.format(t));
        return "index";
    }
}
